//
//  BNMineCollectionListView.m
//  BNCodeGuide
//
//  Created by Mac on 2021/5/22.
//  Copyright © 2021 kevin007. All rights reserved.
//

#import "BNMineCollectionListView.h"

//cell
#import "BNMineNormalCell.h"
#import "BMineImageCell.h"

//header footer
#import "BNMineHeaaderFooterReusableView.h"

@implementation BNMineCollectionListView
#pragma mark - -------------UICollectionViewDataSource----------------
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
    return 50;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return 2;
}

- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section % 2 == 0) {
        BNMineNormalCell *cell = [BNMineNormalCell cellFromClassWithCollectionView:collectionView forIndexPath:indexPath];
        cell.contentView.backgroundColor = [UIColor randomColor];
        cell.titleLabel.text = [NSString stringWithFormat:@"%ld - %ld",indexPath.section, indexPath.row];
        return cell;
    } else {
        BMineImageCell *cell = [BMineImageCell cellFromXibWithCollectionView:collectionView forIndexPath:indexPath];
        cell.contentView.backgroundColor = [UIColor randomColor];
        return cell;
    }
}

- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath {
    BNMineHeaaderFooterReusableView *headerFooter = [BNMineHeaaderFooterReusableView headerReusableViewFromXibWithCollectionView:collectionView forIndexPath:indexPath];
    headerFooter.titleLabel.text = [kind isEqualToString:UICollectionElementKindSectionHeader]?@"Header":@"Footer";
    headerFooter.backgroundColor = [UIColor randomColor];
    
    return headerFooter;
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section {
    return CGSizeMake(UIScreen.width, 50);
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section {
    return CGSizeMake(UIScreen.width, 50);
}

@end
